#!/usr/bin/env python
# -*- coding: utf-8 -*-

from aioredis import create_redis_pool
import asyncio


async def test_redis():
    redis = await create_redis_pool("redis://localhost:6379", db=0, password=None, encoding="utf-8")

    try:
        # 查询所有键
        keys = await redis.keys('*')
        print(keys)
        # await redis.set("key4", "value4")
        test = await redis.get("test")
        print(test)
    finally:
        redis.close()
        await redis.wait_closed()


if __name__ == '__main__':
    asyncio.run(test_redis())



